import Vue from 'vue'
import VeeValidate from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN"; // 引入中文message

Vue.use(VeeValidate)
//务必在使用当前插件之后再进行配置
VeeValidate.Validator.localize("zh_CN", {
    messages: {
        ...zh_CN.messages,
        is: (field) => `${field}必须与密码相同`, // 修改内置规则的message
    },
    attributes: {
        // 给校验的field属性名映射中文名称
        phone: "手机号",
        verify: "验证码",
        password: "密码",
        rePassword: "确认密码",
        agree: "协议"
    },
});
VeeValidate.Validator.extend("agree", {
    //参数value就是接受当前表单的值
    validate: (value) => {
        //我们可以在函数中书写判断条件,如果条件通过则返回true 否则返回false
        /* if(value===true){
          return true
        }else{
          return false
        } */
        return value;
    },
    getMessage: (field) => field + "必须同意",
});